﻿using System;
using System.Collections;
using System.Drawing;

using Storm.TextEditor.Win32;
using Storm.TextEditor.Win32.Structs;

namespace Storm.TextEditor.Core
{
    public class FontEnum
    {
        #region Fields

        private Hashtable fonts = null;

        #endregion

        #region Methods

        #region Public

        public ICollection EnumFonts()
        {
            Bitmap bmp = new Bitmap(10, 10);
            Graphics g = Graphics.FromImage(bmp);

            IntPtr hDC = g.GetHdc();
            fonts = new Hashtable();

            LogFont lf = new LogFont();
            lf.lfCharSet = 1;

            FONTENUMPROC callback = new FONTENUMPROC(CallbackFunc);
            NativeGdi32Api.EnumFontFamiliesEx(hDC, lf, callback, 0, 0);

            g.ReleaseHdc(hDC);
            g.Dispose();
            bmp.Dispose();

            return fonts.Keys;
        }

        #endregion

        #region Private

        private int CallbackFunc(ENUMLOGFONTEX f, int a, int b, int LParam)
        {
            fonts[f.elfLogFont.lfFaceName] = "abc";
            return 1;
        }

        #endregion

        #endregion

        /// <summary>
        /// Initializes a new instance of FontEnum.
        /// </summary>
        public FontEnum()
        {
        }
    }
}
